﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="BorrowBook.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <!--#include virtual="include/Head.ascx"-->
    <link rel="stylesheet" href="Assets/css/EditTableCell.css" type="text/css" />
    <script type='text/javascript' src="Assets/js/jquery-custom-1.0.0.js?v=2011"></script>
    <script type='text/javascript' src="assets/js/BorrowBook.js"></script>
    <link rel="stylesheet" type="text/css" href="assets/css/datepicker.css" />
    <script type='text/javascript' src="assets/js/jquery.ui.datepicker.js"></script>
    <script>
        $(document).ready(function () {
            $("#txtFrom").datepicker({ dateFormat: "dd-mm-yy" });
            $("#txtTo").datepicker({ dateFormat: "dd-mm-yy" });
        });
    </script>
    <style type="text/css">
        .thheader{
        font-weight:bold;vertical-align:middle;text-align:center;
        font-size:11px;
        border:1px solid #ccc !important;
        line-height: 7px !important;;
        }
    </style>
    <script type="text/javascript">

        function getUrlVars() {
            var vars = {};
            var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {
                vars[key] = value;
            });
            return vars;
        }
        function doDelete(strID, strName) {
            if (confirm('Bạn có thực sự muốn xóa ' + strName + '?')) {
                var vnpage = getUrlVars()['page_number'];
                var vChar = getUrlVars()['letter'];
                var strHref = "";
                if (vnpage)
                    strHref = "BorrowBook.aspx?action=delete&ID=" + strID + "&page_number=" + vnpage;
                else
                    strHref = "BorrowBook.aspx?action=delete&ID=" + strID;

                if (vChar)
                    window.location.href = strHref + "&letter=" + vChar;
                else
                    window.location.href = strHref;
            }
        }
        jQuery("document").ready(function () {
            jQuery("#txtFileNumber").blur(function () {
                jQuery.ajax({
                    type: "POST",
                    url: "AjaxFile/GetCostNo.ashx",
                    success: function (msg) {
                        var arrSource = msg.split(",");
                        $('#txtFileNumber').autocomplete(arrSource);
                    }
                });
            }).blur();
        });
    </script>
</head>
<body>
    <div id="body-wrapper">
        <div id="header">
            <!--#include virtual="include/top.ascx"-->
        </div>
        <div id="main-content1">
            <h2>
                SỔ VAY
                <%=Province %>
            </h2>
            <div class="clear">
            </div>
            <div class="content-box">
                <form id="frmEdit" runat="server">
                <%if (nPermissions >= 3)
                      {%>
                <div id="addnewbox" style="display: none;">
                    <table class="adminedit" style="width: 100%;">
                        <tr style="background: #ECECEC;">
                            <th align="center" rowspan="2" class="thheader">
                                Ngày tháng
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Số File
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Đối tượng
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Diễn giải
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Bank
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Lãi suất
                            </th>
                            <th align="center" colspan="2" class="thheader">
                                TKĐƯ
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Số tiền nhận nợ
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Số tiền đã trả
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Ngày nhận nợ
                            </th>
                            <th align="center" rowspan="2" class="thheader">
                                Thời hạn vay
                            </th>
                        </tr>
                        <tr style="background: #ECECEC; font-weight: bold; vertical-align: middle; text-align: center;">
                            <th align="center" class="thheader">
                                Nợ
                            </th>
                            <th align="center" class="thheader">
                                Có
                            </th>
                        </tr>
                        <tr>
                            <td>
                                <asp:TextBox class="cls" ID="txtCreateDate" runat="server" Width="100px" TabIndex="2"
                                    onkeyup="dtval(this,event)" MaxLength="10" onblur="setFocus(this);"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtFileNumber" runat="server" Width="100px" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtPaymentSubject" runat="server" Width="50px" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtDescription" runat="server" Width="200px" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddBankName" runat="server">
                                    <asp:ListItem Text="TM" Value="TM"></asp:ListItem>
                                    <asp:ListItem Text="VCB" Value="VCB"></asp:ListItem>
                                    <asp:ListItem Text="BIDV" Value="BIDV"></asp:ListItem>
                                    <asp:ListItem Text="TCB" Value="TCB"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtInterest" runat="server" Width="50px" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtReciprocalAccount_Had" runat="server" Width="50px"
                                    TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtReciprocalAccount_Debt" runat="server" Width="50px"
                                    TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtAmount_Debt" runat="server" Width="50px" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtAmount_Paid" runat="server" Width="50px" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtDate_Debt" runat="server" Width="100px" TabIndex="2"
                                    onkeyup="dtval(this,event)" MaxLength="10" onblur="setFocus(this);"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtDuration" runat="server" Width="50px" TabIndex="2"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                    <table class="paramlist admintable" width="100%">
                        <tr>
                            <td colspan="2">
                                <asp:Button class="button" ID="btnSave" runat="server" TabIndex="19" Text="Save"
                                    OnClick="btnSave_Click" />
                            </td>
                        </tr>
                    </table>
                </div>
                <%} %>
                <div class="content-box-header">
                    <h3 style="cursor: s-resize;">
                        SỔ VAY
                        <% =Province%>
                    </h3>
                    <%if (nPermissions > 7)
                          { %>
                    <asp:DropDownList ID="ddProvince" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddProvince_SelectedIndexChanged">
                    </asp:DropDownList>
                    <%} %>
                    <asp:DropDownList ID="ddFundsBank" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddFundsBank_SelectedIndexChanged">
                        <asp:ListItem Text="Select" Value=""></asp:ListItem>
                        <asp:ListItem Text="TM" Value="TM"></asp:ListItem>
                        <asp:ListItem Text="VCB" Value="VCB"></asp:ListItem>
                        <asp:ListItem Text="BIDV" Value="BIDV"></asp:ListItem>
                        <asp:ListItem Text="TCB" Value="TCB"></asp:ListItem>
                    </asp:DropDownList>
                    <asp:TextBox ID="txtFrom" CssClass="calendar-icon" runat="server" value="From" onclick="if(this.value=='From'){this.value=''; this.style.color='#000'}"
                        onblur="if(this.value==''){this.value='From'; this.style.color='#555'}" Width="125px"></asp:TextBox>
                    <asp:TextBox ID="txtTo" CssClass="calendar-icon" runat="server" value="To" Width="125px"
                        onclick="if(this.value=='To'){this.value=''; this.style.color='#000'}" onblur="if(this.value==''){this.value='To'; this.style.color='#555'}"></asp:TextBox>
                    &nbsp;<asp:Button ID="btnSearch" runat="server" Text="&nbsp;Seach&nbsp;" CssClass="button"
                        OnClick="btnSearch_Click" />
                    <input id="btnAddNew" type="button" style="float: right; margin: 9px 10px;" class="button"
                        value="Add new" />
                    <%if (nPermissions > 7)
                          { %>
                    <asp:Button ID="btnCloseFile" Style="float: right; margin: 9px 10px;" CssClass="button"
                        runat="server" Text="&nbsp;Close&nbsp;" OnClick="btnCloseFile_Click" />
                    <%} %>
                    <div class="clear">
                    </div>
                </div>
                <asp:Repeater ID="rptData" runat="server">
                    <ItemTemplate>
                        <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'"
                            borrowbookid='<%#Eval("ID") %>'>
                            <td>
                                <%# DataBinder.Eval(Container.DataItem, "Index")%>
                            </td>
                            <td editable="true" code="CreateDate" onkeyup="dtval(this,event)" maxlength="10"
                                onblur="setFocus(this);">
                                <%# DataBinder.Eval(Container.DataItem, "CreateDate")%>
                            </td>
                            <td editable="true" code="FileNumber" completesource="vFileNumber">
                                <%# DataBinder.Eval(Container.DataItem, "FileNumber")%>
                            </td>
                            <td editable="true" code="PaymentSubject">
                                <%# DataBinder.Eval(Container.DataItem, "PaymentSubject")%>
                            </td>
                            <td editable="true" code="Description">
                                <%# DataBinder.Eval(Container.DataItem, "Description")%>
                            </td>
                            <td editable="true" code="BankName">
                                <%# DataBinder.Eval(Container.DataItem, "BankName")%>
                            </td>
                            <td editable="true" code="Interest">
                                <%# DataBinder.Eval(Container.DataItem, "Interest")%>
                            </td>
                            <td editable="true" code="ReciprocalAccount_Had">
                                <%# DataBinder.Eval(Container.DataItem, "ReciprocalAccount_Had")%>
                            </td>
                            <td editable="true" code="ReciprocalAccount_Debt">
                                <%# DataBinder.Eval(Container.DataItem, "ReciprocalAccount_Debt")%>
                            </td>
                            <td editable="true" code="Amount_Debt">
                                <%# DataBinder.Eval(Container.DataItem, "Amount_Debt")%>
                            </td>
                            <td editable="true" code="Amount_Paid">
                                <%# DataBinder.Eval(Container.DataItem, "Amount_Paid")%>
                            </td>
                            <td editable="false" code="Amount_Owed">
                                <%# DataBinder.Eval(Container.DataItem, "Amount_Owed")%>
                            </td>
                            <td editable="true" code="Duration">
                                <%# DataBinder.Eval(Container.DataItem, "Duration")%>
                            </td>
                            <td editable="true" code="Date_Debt">
                                <%# DataBinder.Eval(Container.DataItem, "Date_Debt")%>
                            </td>
                            <td editable="false" code="Date_Expiration">
                                <%# DataBinder.Eval(Container.DataItem, "Date_Expiration")%>
                            </td>
                            <td>
                                <%# DataBinder.Eval(Container.DataItem, "Action")%>
                            </td>
                        </tr>
                    </ItemTemplate>
                    <HeaderTemplate>
                        <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist"
                            editcellcontent="true">
                            <thead>
                                <tr style="background: #ECECEC;">
                                    <th align="center" rowspan="2" class="thheader" width="30px">
                                        Index
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Ngày tháng
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Số File
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Đối tượng
                                    </th>
                                    <th align="center" rowspan="2" class="thheader" width="200px">
                                        Diễn giải
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Bank
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Lãi suất
                                    </th>
                                    <th align="center" colspan="2" class="thheader">
                                        TKĐƯ
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Số tiền nhận nợ
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Số tiền đã trả
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Số tiền còn nợ
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Thời hạn vay
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Ngày nhận nợ
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Ngày đáo hạn
                                    </th>
                                    <th align="center" rowspan="2" class="thheader">
                                        Action
                                    </th>
                                </tr>
                                <tr style="background: #ECECEC; font-weight: bold; vertical-align: middle; text-align: center;">
                                    <th align="center" class="thheader">
                                        Nợ
                                    </th>
                                    <th align="center" class="thheader">
                                        Có
                                    </th>
                                </tr>
                            </thead>
                    </HeaderTemplate>
                    <FooterTemplate>
                        <tr>
                            <td colspan="9" style="text-align: right; padding-right: 20px !important; font-weight: 600 !important;">
                                Tổng phát sinh
                            </td>
                            <td style="font-weight: bold;">
                                <%= Total_Amount_Debt >0 ? Total_Amount_Debt.ToString("0,0.##") :""%>
                            </td>
                            <td style="font-weight: bold;">
                                <%= Total_Amount_Paid >0 ? Total_Amount_Paid.ToString("0,0.##") :""%>
                            </td>
                            <td style="font-weight: bold;">
                                <%= Total_Amount_Owed >0 ? Total_Amount_Owed.ToString("0,0.##") :""%>
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                        </tr>
                        </TABLE>
                    </FooterTemplate>
                </asp:Repeater>
                <div class="clear">
                </div>
                <div id="footer">
                    <%=strPager%>
                </div>
                </form>
            </div>
        </div>
    </div>
</body>
</html>
